@extends('Home.User.Common.layout')
@section('title')
    登录日志_设置
@endsection
@section('content')
    <!--  content  -->
    <main class="common_content">
        <div class="container">
            <div class="ct_main">
                @include('Home.User.Set.Common.set_menu')
                <ul class="nav-items1 nav-items2 w999" id="tab-content2">
                    <!--基本设置-->
                    <li class="basic-sets active">
                        <div class="selector-head">
                            <h2>基本设置</h2>
                        </div>
                        <!--登录日志-->
                        <ul>
                            <li>
                                <h2 class="basic-title" style="margin-top: 10px;position: relative;">
                                    登录日志
                                    <div class="layui-form" style="display: inline-block;position: absolute;right: 0;top: -7px;">
                                        <div class="layui-select-tips" style="width: 100px;">
                                            <select name="uid" lay-filter="uid">
                                                <option value="" @if(!$uid) selected @endif>全员</option>
                                                @foreach($user_list as $user)
                                                    <option value="{{$user->id}}" @if($uid == $user->id) selected @endif>{{$user->username}}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>
                                </h2>
                                <div class="layui-form">
                                    <table class="layui-table">
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>姓名</th>
                                            <th>职位</th>
                                            <th>登录时间</th>
                                            <th>登录位置/IP</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($list as $item)
                                            <tr>
                                                <td>{{$item->id}}</td>
                                                <td>{{$item->user?$item->user->username:''}}</td>
                                                @if($item->user)
                                                    @if($item->user->frame)
                                                        @switch($item->user->frame->level)
                                                            @case(1)
                                                            <td>经理</td>
                                                            @break
                                                            @case(2)
                                                            <td>主管</td>
                                                            @break
                                                            @case(3)
                                                            <td>职员</td>
                                                            @break
                                                            @default
                                                            <td>未知</td>
                                                        @endswitch
                                                    @else
                                                        <td></td>
                                                    @endif
                                                @else
                                                    <td></td>
                                                @endif
                                                <td>{{$item->created_at}}</td>
                                                <td>{{$item->ip}}</td>
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    </table>

                                    <!-- 分页 s -->
                                    @if($num>1)
                                        <div class="news-pager">
                                            <ul class="pagination" id="page">
                                            </ul>
                                            <div class="pageJump">
                                                <span>跳转到</span>
                                                <input type="text"/>
                                                <span>页</span>
                                                <button type="button" class="button">确定</button>
                                            </div>
                                        </div>
                                @endif
                                <!-- 分页 e -->
                                </div>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </main>
@endsection
@section('footer')
    <script>
        /***  分页 JS  ***/
        Page({
            num: '{{$num}}',		//页码数
            startnum: '{{$page}}',	//指定页码
            elem:$('#page'),		//指定的元素
            callback:function(n){	//回调函数
                window.location.href = '{{route('login_log',['uid'=>$uid])}}&page='+n;
            }
        });
        layui.use(['table','form', 'layer', 'upload','element'], function(){
            var form = layui.form
                form.on('select(uid)', function(data){
                    if (data.value) {
                        window.location.href = '{{route('login_log','')}}&uid='+data.value;
                    }else {
                        window.location.href = '{{route('login_log')}}';

                    }
            });
        });
    </script>
@endsection
@include('Home.User.Common._footer')